import minimist from 'minimist';
import { Compiler } from '../compiler';
import { Config, Mode } from '../core';

enum Command {
  BUILD = 'build',
  DEV = 'dev',
}

export async function main() {
  const args = minimist(process.argv.slice(2));
  const command = args._[0];

  if (command === Command.DEV || command === Command.BUILD) {
    const isDev = command === Command.DEV;
    const config = new Config(isDev ? Mode.Development : Mode.Production);

    const compiler = new Compiler(config);
    await compiler.compile();

    return;
  }

  console.log("Usage: pack dev/build");
}
